package com.ruoyi.web.controller.yijing;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yijing.domain.YjDaShang;
import com.ruoyi.yijing.service.IYjDaShangService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 打赏的礼物Controller
 * 
 * @author ruoyi
 * @date 2024-01-22
 */
@RestController
@RequestMapping("/yijing/shang")
public class YjDaShangController extends BaseController
{
    @Autowired
    private IYjDaShangService yjDaShangService;

    /**
     * 查询打赏的礼物列表
     */
    //@PreAuthorize("@ss.hasPermi('yijing:shang:list')")
    @GetMapping("/list")
    public TableDataInfo list(YjDaShang yjDaShang)
    {
        startPage();
        List<YjDaShang> list = yjDaShangService.selectYjDaShangList(yjDaShang);
        return getDataTable(list);
    }

    /**
     * 获取打赏的礼物详细信息
     */
    //@PreAuthorize("@ss.hasPermi('yijing:shang:query')")
    @GetMapping(value = "/{shangId}")
    public AjaxResult getInfo(@PathVariable("shangId") Long shangId)
    {
        return success(yjDaShangService.selectYjDaShangByShangId(shangId));
    }

    /**
     * 新增打赏的礼物
     */
    //@PreAuthorize("@ss.hasPermi('yijing:shang:add')")
    @Log(title = "打赏的礼物", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YjDaShang yjDaShang)
    {
        return toAjax(yjDaShangService.insertYjDaShang(yjDaShang));
    }

    /**
     * 修改打赏的礼物
     */
    //@PreAuthorize("@ss.hasPermi('yijing:shang:edit')")
    @Log(title = "打赏的礼物", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YjDaShang yjDaShang)
    {
        return toAjax(yjDaShangService.updateYjDaShang(yjDaShang));
    }

    @Log(title = "修改礼物状态", businessType = BusinessType.UPDATE)
    @PutMapping("updateStatus")
    public AjaxResult updateStatus(@RequestBody YjDaShang yjDaShang)
    {
        return toAjax(yjDaShangService.updateYjDaShang(yjDaShang));
    }


    /**
     * 删除打赏的礼物
     */
    //@PreAuthorize("@ss.hasPermi('yijing:shang:remove')")
    @Log(title = "打赏的礼物", businessType = BusinessType.DELETE)
	@DeleteMapping("/{shangIds}")
    public AjaxResult remove(@PathVariable Long[] shangIds)
    {
        return toAjax(yjDaShangService.deleteYjDaShangByShangIds(shangIds));
    }
}
